package com.ruoyi.loupan.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.loupan.domain.TbRelationPremisesProperty;
import com.ruoyi.loupan.service.ITbRelationPremisesPropertyService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 楼盘-特色Controller
 * 
 * @author wukaige
 * @date 2021-07-01
 */
@RestController
@RequestMapping("/property")
public class TbRelationPremisesPropertyController extends BaseController
{
    @Autowired
    private ITbRelationPremisesPropertyService tbRelationPremisesPropertyService;

    /**
     * 查询楼盘-特色列表
     */
    @PreAuthorize(hasPermi = "system:property:list")
    @GetMapping("/list")
    public TableDataInfo list(TbRelationPremisesProperty tbRelationPremisesProperty)
    {
        startPage();
        List<TbRelationPremisesProperty> list = tbRelationPremisesPropertyService.selectTbRelationPremisesPropertyList(tbRelationPremisesProperty);
        return getDataTable(list);
    }

    /**
     * 导出楼盘-特色列表
     */
    @PreAuthorize(hasPermi = "system:property:export")
    @Log(title = "楼盘-特色", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbRelationPremisesProperty tbRelationPremisesProperty) throws IOException
    {
        List<TbRelationPremisesProperty> list = tbRelationPremisesPropertyService.selectTbRelationPremisesPropertyList(tbRelationPremisesProperty);
        ExcelUtil<TbRelationPremisesProperty> util = new ExcelUtil<TbRelationPremisesProperty>(TbRelationPremisesProperty.class);
        util.exportExcel(response, list, "楼盘-特色数据");
    }

    /**
     * 获取楼盘-特色详细信息
     */
    @PreAuthorize(hasPermi = "system:property:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tbRelationPremisesPropertyService.selectTbRelationPremisesPropertyById(id));
    }

    /**
     * 新增楼盘-特色
     */
    @PreAuthorize(hasPermi = "system:property:add")
    @Log(title = "楼盘-特色", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbRelationPremisesProperty tbRelationPremisesProperty)
    {
        return toAjax(tbRelationPremisesPropertyService.insertTbRelationPremisesProperty(tbRelationPremisesProperty));
    }

    /**
     * 修改楼盘-特色
     */
    @PreAuthorize(hasPermi = "system:property:edit")
    @Log(title = "楼盘-特色", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbRelationPremisesProperty tbRelationPremisesProperty)
    {
        return toAjax(tbRelationPremisesPropertyService.updateTbRelationPremisesProperty(tbRelationPremisesProperty));
    }

    /**
     * 删除楼盘-特色
     */
    @PreAuthorize(hasPermi = "system:property:remove")
    @Log(title = "楼盘-特色", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbRelationPremisesPropertyService.deleteTbRelationPremisesPropertyByIds(ids));
    }
}
